﻿<%@ Page Title="" Language="C#" MasterPageFile="~/layout/admin.Master" AutoEventWireup="true" CodeBehind="EditArticle.aspx.cs" Inherits="SinhNhat.admin.EditArticle" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentMain" runat="server">

    <script type="text/javascript">
        function Valid() {
            var valid = true;


            var errorStr = "";
            var txtTitle = document.getElementById("<%=txtTitle.ClientID %>");
            var txtContent = CKEDITOR.instances.<%=txtContent.ClientID%>.getData();

            if (txtTitle.value == '') {
                txtTitle.setAttribute('class', 'textValid');
                errorStr += "<li style='color:red;'>Nhập tiêu đề</li>";
                txtTitle.focus();
                valid = false;
            }
            else {
                txtTitle.setAttribute('class', '');
            }

//            if (txtURL.value == '') {
//                txtURL.setAttribute('class', 'textValid');
//                errorStr += "<li style='color:red;'>Nhập URL</li>";
//                txtURL.focus();
//                valid = false;
//            }
//            else {
//                txtURL.setAttribute('class', '');
//            }

            if (txtContent == '') {
                errorStr += "<li style='color:red;'>Nhập nội dung</li>";
                //txtContent.focus();
                valid = false;
            }

            if (valid == false) {
                errorStr = "<ul>" + errorStr + "</ul>";
            }

            document.getElementById("divError").innerHTML = errorStr;
            return valid;
        }
    </script>
        
    <asp:HiddenField ID="hdArticleID" runat="server" />
    <asp:HiddenField ID="hdUrlOdl" runat="server" />

    <h2>
        <asp:Label ID="lblHeader" runat="server" />
    </h2>

    <table>
        <tr>
            <td style="width:100px">Title</td>
            <td>
                <asp:TextBox ID="txtTitle" runat="server" Width="500px" />
            </td>
        </tr>
        <%--<tr>
            <td>URL</td>
            <td>
                <asp:TextBox ID="txtURL" runat="server" Width="500px" />
            </td>
        </tr>--%>
        <tr>
            <td>Content</td>
            <td>
                <CKEditor:CKEditorControl ID="txtContent" runat="server" Width="666px" Height="400px"></CKEditor:CKEditorControl>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <div id="divError"></div>
                <asp:Literal ID="lblError" runat="server" Text="<ul><li style='color:red;'>URL đã tồn tại</li></ul>" Visible="false" Mode="PassThrough" />
            </td>
        </tr>
        <tr>
            <td align="center" colspan="2">
            
                <asp:Button ID="btnSave" runat="server" OnClientClick="return Valid();" Text="Save" CssClass="button_colour round_all" />

                <%--<button id="btnSave" class="button_colour round_all" runat="server" onclick="return Valid();" >
                    <img height="24" width="24" alt="Bended Arrow Right" src="/data/theme/admin/image/Bended_Arrow_Right.png">
                    <span>Lưu kết quả</span>
                </button>--%>
            </td>
        </tr>
    </table>
    
</asp:Content>
